#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2022/5/20 10:57
# @Author    :cjw
import logging

from selenium.webdriver.common.by import By

from web_wework.page.base_page import BasePage


class ContactPage(BasePage):
	"""通讯录页面"""

	__BTN_ADD_MEMBER = (By.CSS_SELECTOR, '.ww_operationBar>.js_add_member')  # “添加成员”按钮
	__BTN_ADD = (By.CSS_SELECTOR, '.member_colLeft_top_addBtnWrap')  # “+”号按钮
	__BTN_ADD_DEPARTMENT = (By.XPATH, '//a[text()="添加部门"]')  # “添加部门”按钮
	__TEXT_TIPS = (By.ID, 'js_tips')  # 冒泡信息

	def goto_add_member(self):
		"""跳转到添加成员页面"""
		from web_wework.page.add_member_page import AddMemberPage

		logging.info('跳转到添加成员页面')
		self.click(self.__BTN_ADD_MEMBER)
		return AddMemberPage(self.driver)

	def goto_add_department(self):
		"""跳转到添加部门页面"""
		from web_wework.page.add_department_page import AddDepartmentPage

		logging.info('跳转到添加部门页面')
		self.click(self.__BTN_ADD)
		self.click(self.__BTN_ADD_DEPARTMENT)
		return AddDepartmentPage(self.driver)

	def get_tips(self):
		"""获取冒泡信息"""
		logging.info('获取冒泡信息')
		tips_element = self.find(self.__TEXT_TIPS)
		return tips_element.text
